import { createApp } from 'vue'
import { createPinia } from 'pinia'
import './styles/reset.scss'
import App from './App.vue'
import router from './router'
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'
import 'element-plus/dist/index.css'
import ElementPlus from 'element-plus'
import zhCn from 'element-plus/es/locale/lang/zh-cn'
import * as directives from '@/directives/index'
import type { Directive } from 'vue'

const app = createApp(App)
const pinia = createPinia()
app.use(pinia)

app.use(router)

app.use(ElementPlus, {
  locale: zhCn,
})

// 循环注册全局自定义指令
for (let k in directives) {
  // app.directive(k, directives as Directive)
  app.directive(k, directives[k as keyof Directive])
}
pinia.use(piniaPluginPersistedstate)
app.mount('#app')
